<template>
  <div class="amendPsw">
    <div class="content">
				<div class="area">
						<div class="public">
							<ul>
								<li>
									<dl>
										<dt>当前密码</dt>
										<dd><input name="" v-model="oldPwd" type="password" /></dd>
									</dl>
								</li>
								<li>
									<dl>
										<dt>新密码</dt>
										<dd><input name="" v-model="newPwd" type="password" /></dd>
									</dl>
								</li>
								<li>
									<dl>
										<dt>确认密码</dt>
										<dd><input name="" v-model="sureNewPwd" type="password" /></dd>
									</dl>
								</li>
							</ul>
							<a href="javascript:;" @click="updatePwd" class="btn_org_pas">保存设置</a>
						</div>
					</div>
			</div>
  </div>
</template>
<script>
import commonJs from "@/common/js/common";
export default {
  name: "amendPsw",
  data() {
    return {
      oldPwd: "",
      newPwd: "",
      sureNewPwd: ""
    };
  },
  mounted() {
    this.devId = localStorage.getItem("devId");
    this.token = localStorage.getItem("token");
  },
  methods: {
    // 修改密码
    updatePwd() {
      if (this.newPwd != this.sureNewPwd) {
        this.$message({
          type: "warning",
          message: "新密码和确认密码不一致！"
        });
        return;
      }
      if (this.newPwd == "" || this.oldPwd == "" || this.sureNewPwd == "") {
        this.$message({
          type: "warning",
          message: "你的信息未填写完整！"
        });
        return;
      }
      this.$http({
        method: "POST",
        url: commonJs.BASE_URL + "/developer/update_pwd.do",
        data: `id=${this.devId}&token=${this.token}&oldPwd=${
          this.oldPwd
        }&newPwd=${this.newPwd}`
      }).then(res => {
        if (res.data.code == 0) {
          this.$message({
            type: "success",
            message: res.data.message
          });
          this.oldPwd = "";
          this.newPwd = "";
          this.sureNewPwd = "";
        } else {
          this.$message({
            type: "warning",
            message: res.data.message
          });
        }
      });
    }
  }
};
</script>

<style scoped>
.withdrawal {
  height: 100%;
}
.main .content {
  width: 80%;
  margin: 20px auto;
}
.area {
  border: 1px solid #ebebeb;
  padding: 20px;
  margin-bottom: 20px;
  position: relative;
}
.public {
  width: 500px;
  margin: 10px auto;
}
.public ul {
}
.public ul li {
  width: 100%;
  height: auto;
  margin-bottom: 20px;
  position: relative;
  border: none;
}
.public ul li dl {
  position: relative;
}
.public ul li dl dt {
  position: absolute;
  top: 6px;
  left: 0px;
  width: 74px;
  text-align: right;
}
.public ul li dl dd {
  height: 30px;
  margin-left: 86px;
  border: 1px solid #cccccc;
}
.public ul li dl dd input {
  height: 30px;
  line-height: 30px;
  width: 90%;
  border: none;
  background: none;
  margin-left: 50px;
  outline: none;
}
.public ul li dl dd a:link,
.public ul li dl dd a:visited {
  margin-left: 0px;
  width: 76px;
  height: 76px;
  border: 1px dashed #bbb;
  display: block;
  line-height: 76px;
  text-align: center;
  color: #666;
}
.public a {
  margin-left: 86px;
}
.amendPsw .btn_org_pas {
  display: inline-block;
  padding: 0px 10px;
  height: 28px;
  line-height: 28px;
  color: #fff;
  text-align: center;
  border: 1px solid #fa8b00;
  background: #fa8b00;
  font-size: 14px;
}
</style>
